global class EmailVelocityIgnoreHandler
{
    public static void enable(String FromAddy, String ToAddy, Integer Thresh)
    {
        List<EmailVelocityIgnore__c> vecs = [Select Id, ToAddress__c, FromAddress__c, IsActive__c, Threshold__c From EmailVelocityIgnore__c where FromAddress__c = :FromAddy and ToAddress__c = :ToAddy];
        EmailVelocityIgnore__c ignore = new EmailVelocityIgnore__c();
        
        if (vecs.size() < 1)
        {
            // brand new vector
                   
            ignore.ToAddress__c = ToAddy;
            ignore.FromAddress__c = FromAddy;
            ignore.Threshold__c = Thresh;
            ignore.IsActive__c = true;
            insert ignore;     
        }
        else
        {
            // "there can be only one!"
            ignore = vecs[0];
            ignore.Threshold__c = Thresh;
            ignore.IsActive__c = true;
            update ignore; 
        }        
    }
    
    public static void disable(String FromAddy, String ToAddy)
    {
        List<EmailVelocityIgnore__c> vecs = [Select Id, ToAddress__c, FromAddress__c, IsActive__c, Threshold__c From EmailVelocityIgnore__c where FromAddress__c = :FromAddy and ToAddress__c = :ToAddy];
        EmailVelocityIgnore__c ignore = new EmailVelocityIgnore__c();
        
        if (vecs.size() > 0)
        {
            ignore = vecs[0];
            ignore.IsActive__c = false;
            update ignore; 
        }        
    }
    
    
    public static List<EmailVelocityIgnore__c> getBlackList()
    {
        return [Select Id, ToAddress__c, FromAddress__c, IsActive__c, Threshold__c From EmailVelocityIgnore__c where IsActive__c = True and Threshold__c = 0];
    }
    
    public static List<EmailVelocityIgnore__c> getActive()
    {
        return [Select Id, ToAddress__c, FromAddress__c, IsActive__c, Threshold__c From EmailVelocityIgnore__c where IsActive__c = True];
    }
    
    public static List<EmailVelocityIgnore__c> get(String FromAddy, String ToAddy)
    {
        return [Select Id, ToAddress__c, FromAddress__c, IsActive__c, Threshold__c From EmailVelocityIgnore__c where FromAddress__c = :FromAddy and ToAddress__c = :ToAddy];
    }
}